package com.zelin.test;

import com.zelin.pojo.student;
import com.zelin.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.List;



public class testMybatis {

    private MyBatisUtils myBatisUtils;
    @Before
    public void init(){
        myBatisUtils = new MyBatisUtils();
    }
    @Test
    public void test01() throws IOException {
        //1.得到sqlSession对象
        SqlSession sqlSession = myBatisUtils.getSqlSession(true);
        //2.查询所有学生列表
        List<student> students = sqlSession.selectList("test.findAll");
        //3.打印
        for (student student : students) {
            System.out.println(student);
        }
        //4.关闭
        sqlSession.close();
    }
}
